﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Practices.EnterpriseLibrary.Data;
using System.Data;
using DigtiMatrix.Entity;
using DigitMatrix.DataAccess;
using log4net;
using System.IO;
using System.Reflection;
using System.Threading;
using System.Drawing;

namespace DigitMatrix.Business
{
    public class DeviceDriver:IDisposable
    {
       
        private DeviceInfo _deviceInfo = null;
        public int TotalDSP { get; set; }
        public bool IsValid { get; set; }

        public DeviceDriver(DeviceInfo deviceInfo)
        {
            _deviceInfo = deviceInfo;
        }
        public bool Init(ref string errMessage)
        {
            HikVisionSDK.SetDefaultVideoStandard(VideoStandard_t.StandardNTSC);

            //初始化板卡
            IsValid = false;
            if (HikVisionSDK.InitDSPs() < 0)
            {
                errMessage = "设备初始化失败";
                
                return false;
            }
            TotalDSP =  HikVisionSDK.GetTotalDSPs();
            if (TotalDSP == 0)
            {
                errMessage = "没有可用的通道！！您是否已经启动服务器端？";
                return false;
            }
            IsValid = true;
            return true;
        }
        public int Close()
        {
            return HikVisionSDK.DeInitDSPs();
        }

        #region IDisposable 成员

        public void Dispose()
        {
            HikVisionSDK.DeInitDSPs();
        }

        #endregion
    }
}
